<?php
//	echo "<pre>";
//	var_dump($request_role);
//	print_r($_POST);
//	echo "</pre>";
//	die();
?>
<link rel="stylesheet" href="<?php echo base_url() ?>css/jquery.ui.all.min.css" type="text/css" title="ui-theme" />
<script type="text/javascript" src="<?php echo base_url() ?>js/ui/jquery-ui.min.js"></script>
<style>
	.xmen.din{
		margin-bottom: 30px;
	}
	#isi_table{
		color: black;
		background: white;
		margin: 0;
		padding: 0;
	}
	tbody#isi_table tr td {
		padding-top: 10px;
		padding-bottom: 10px;
		text-align: center;
	}
	#daftar_role_length {
		float: left;
		padding: 10px;
	}
	#daftar_role_filter {
		float: right;
		padding: 10px;
	}
	input, select {
		font-size: 12pt;
		border: 1px solid #111;
		background-color: #222;
		color: #EEE;
		padding-top: 8px;
		padding-right: 6px;
		padding-bottom: 8px;
		padding-left: 6px;
		font-family: "Century Gothic";
		cursor: pointer;
		margin-right: 5px;
	}
	select:focus, input:focus {
		background-color: #CCC;
		border: 1px solid #390;
		color: black;
		-moz-border-radius: 3px;
		border-radius: 3px;
		cursor: pointer;
	}
	#daftar_role_wrapper {
		clear: both;
		font-size: 14px;
	}
</style>
<div id="isikiri">
    <div id="tempatfoto">
        <img src="<?php echo base_url() . "/foto/" . $this->session->userdata('foto'); ?>" width="267" height="400" />
	</div>
    <p>&nbsp;</p>
</div>
<!---mulai div isikanan --->
<div id="isikanan">
	<div class="din pel"><?php echo $this->session->userdata('nama'); ?><span class="black">Edit</span></div>
	<?php echo $this->load->view("schedule/profile_nav") ?>
	<div class="clear"></div>
	<!---mulai div biodata --->
	<div id="biodata">

		<div id="tambah_role">
			<div class="xmen din" style="margin-top: 20px">Tambah Role</div>
			<div>
				<form method="post" action="<?php echo current_url(); ?>">
					<div class="judulform">Kode Pelatihan</div>
					<?php echo form_dropdown('kode_pelatihan', $courses, $request_role['kode_pelatihan'], "class='isian f0' id='select2' onchange='this.form.submit()'"); ?>
				</form>

				<?php if (($request_role['kode_pelatihan'] == "-") || (empty($request_role['kode_pelatihan']))) { ?>
					<div class="judulform din">Pilih kode Pelatihan</div>
				<?php } else { ?>
					<div class="judulform din"><?php echo $request_role['nama_pelatihan']; ?></div>
					<?php echo form_open("schedule/schedule_con/update_role"); ?>
					<input type="hidden" name="kode_pelatihan" value="<?php echo $request_role['kode_pelatihan']; ?>" />
					<div class="judulform">
						<table border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td rowspan="1" valign="top" class="judulform">Sebagai</td>
							</tr>
							<tr>
								<td valign="top">
									<select name="role" class="isian f0" >
										<option value="instruktur">Instruktur</option>
										<option value="asisten">Asisten</option>
									</select>
								</td>
							</tr>
						</table>
					</div>
					<div class="judulform">Availability</div>
					<select class="isian f0" name="tahun_term">
						<?php for ($i = 0; $i < count($request_role['tahun_term']); $i++) { ?>
							<option value="<?php echo $request_role['tahun_term'][$i]['data']; ?>">
								Term-<?php echo $request_role['tahun_term'][$i]['term'] . " " . $request_role['tahun_term'][$i]['tahun']; ?>
							</option>
						<?php } ?>
					</select>
					<input type="hidden" name="count_check" value="<?php echo count($request_role['tahun_term']) ?>" />
					<div class="tempatbutton">
						<input class="save" type="submit" name="button" id="button" value="Save" />
					</div>
					<?php echo form_close(); ?>
				<?php } ?>
			</div>
		</div>
		<div class="xmen din" style="margin-top:30px">Daftar  Role</div>
		<table cellpadding="0" cellspacing="0" border="0" class="display" id="daftar_role">
			<thead>
				<tr>
					<th>Kode Pelatihan</th>
					<th style="width: 5%">Angkatan</th>
					<th>Term</th>
					<th>role</th>
					<th>Edit</th>
					<th>Delete</th>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<th>Kode Pelatihan</th>
					<th>Angkatan</th>
					<th>Term</th>
					<th>role</th>
					<th>Edit</th>
					<th>Delete</th>
				</tr>
			</tfoot>
			<tbody id="isi_table">
				<?php $i = 0 ?>
				<?php foreach ($daftar_role as $row) { ?>
					<tr>
						<td title="<?php echo $row['nama_pelatihan'] ?>"><?php echo $row['kode_pelatihan']; ?> - <?php echo $row['nama_pelatihan'] ?></td>
						<td><?php echo $row['tahun'] ?></td>
						<td><?php echo $row['term'] ?></td>
						<td>
							<?php echo $row['role'] ?>
						</td>
						<td class="center">
							<a id="tmb_role<?php echo $i ?>" href="#edit_role<?php echo $i ?>">Edit</a>
						</td>
						<td class="center">
							<a href="<?php echo base_url() ?>/schedule/schedule_con/delete_role/<?php echo $row['kode_pelatihan'] . "/" . $row['tahun'] . "/" . $row['term']; ?>">Delete</a>
						</td>
					</tr>

				<div id="edit_role<?php echo $i ?>">
					<div class="xmen din">Edit Role</div>
					<h2><?php echo $row['kode_pelatihan'] . "-" . $row['term'] ?>/ <?php echo $row['nama_pelatihan'] ?>/ <?php echo $row['tahun'] ?></h2>
					<form method="post" action="<?php echo base_url() ?>/schedule/schedule_con/change_role/<?php echo $row['kode_pelatihan'] . "/" . $row['tahun'] . "/" . $row['term']; ?>">
						<select name="role_change" class="isian f0" >
							<option value="instruktur" <?php if (strcmp($row['role'], 'instruktur') == 0) echo " selected='selected'" ?>>Instruktur</option>
							<option value="asisten" <?php if (strcmp($row['role'], 'asisten') == 0) echo " selected='selected'" ?>>Asisten</option>
						</select>
						<input class="save" name="button" type="submit" value="simpan"/>
					</form>
				</div>
				<script>
					$("#edit_role<?php echo $i ?>").dialog({
						autoOpen: false,
						height: 300,
						width: 500,
						modal: true
					});
					$("#tmb_role<?php echo $i ?>").click(function(){
						$("#edit_role<?php echo $i ?>").dialog("open");
					});
				</script>
				<?php $i++ ?>
			<?php } ?>
			</tbody>
		</table>
	</div>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
	$(function(){
		$('#daftar_role').dataTable({
			"sScrollY": 'auto',
			"bJQueryUI": true
		});
	})
</script>